.rescol-wrapper.with-borders.columns-list-table
  .rescol-header-wrapper
  .rescol-content-wrapper
    table
      thead
        tr
          th column
          th type
          th max length
          th default
          th primary key
          th null
          th
      tbody
        each column in columns || []
          tr
            td= column.column_name
            td(title = column_type_label(column))= column_type_label(column, true)
            td= column.character_maximum_length
            td= ('' + column.column_default).match(/^nextval/) ? 'auto increment' : column.column_default
            td= column.is_primary_key ? 'yes' : ''
            td= column.is_nullable == 'YES' || column.is_nullable == true ? 'yes' : 'no'
            td
              a(exec="editColumn('" + column.column_name + "')") Edit
              != "&nbsp;"
              a(exec="deleteColumn('" + column.column_name + "')") Delete
        else
          if !columns
            tr
              td(colspan=7)
                = "Error accured while getting table info"
                if columnsError
                  br
                  pre
                    code= columnsError.message

footer
  if !isMatView
    button.native-look(exec="addColumnForm") Add Column

h4 Indexes

.rescol-wrapper.with-borders.indexes-list-table
  .rescol-header-wrapper
  .rescol-content-wrapper
    table
      thead
        tr
          th name
          th p. key
          th uniq
          th columns
          th type
          th size
          th
      tbody
        each index in indexes || []
          tr
            td
              = index.relname
              if !index.indisvalid
                span.tag.error(title="This usually means that error happen while creating index with 'CONCURRENTLY'") invalid
            td= index.indisprimary ? 'Yes' : 'No'
            td= index.indisunique ? 'Yes' : 'No'
            td= index.columns().join(", ")
            td= getIndexType(index.pg_get_indexdef)
            td= index.index_size
            td
              a(exec="deleteIndex('" + index.relname + "')") Delete
        else
          if !indexes
            tr
              td(colspan=6)
                = "Error accured while getting table indexes "
                if indexesError
                  br
                  pre
                    code= indexesError.message

footer
  button.native-look(exec="addIndexForm") Add Index

if constraints.length > 0
  h4 Constraints
  .rescol-wrapper.with-borders.indexes-list-table
    .rescol-header-wrapper
    .rescol-content-wrapper
      table
        thead
          tr
            th name
            th source
            th
        tbody
          each constraint in constraints
            tr
              td= constraint.conname
              td= constraint.pretty_source
              td
                a(exec="deleteConstraint('" + constraint.conname + "')") Delete
